<template>
	<view class="item" @click="onClick(item.id)">
		<view class="title" style="font-weight: bold;">{{item.c_name}}</view>
		<view class="flex vertical-center">
			<image src="../../../../static/icon/adderss.png" mode=""></image>
			<view class="text ellipsis">
				<text>{{item.s_name}}</text>
				<text>{{item.address}}</text>
			</view>
		</view>
		<view class="flex vertical-center">
			<image src="../../../../static/icon/endtime.png" mode=""></image>
			<view class="text ellipsis">
				<text>有效期：{{item.expire_time}}</text>
			</view>
		</view>
		<view class="progress-cont operation-item">
			<view class="progress-text">已完成{{item.finsh_hour}}/{{item.total_hour}}课时</view>
			<view class="progress-box">
				<view class="progress-line" :style="'--width: '+ progress(item.finsh_hour, item.total_hour) + '%'"></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "course_my_item",
		props: {
			item: Object
		},
		data() {
			return {
				// id    【订单id】	 (int)
				// c_name 【课程名称】	 (string)
				// s_name 【门店名称】	 (string)
				// finsh_hour 【完成课时】	 (int)
				// total_hour 【总课时】	   (int)
				// expire_time	【有效期】	 (string)
				// is_finsh  【是否已完结 0未完结 1已完结】  (int)
			};
		},
		methods: {
			progress(x, y) {
				return (x / y) * 100
			},
			onClick(id) {
				this.onGoNext(`/pages/course/my-course/my-course?id=${id}`)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item{
		padding: 17rpx 25rpx;
		background-color: $color-white;
		border-radius: 5rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 0 10rpx rgba(#888, .1);
		position: relative;
		.title{
			font-size: 28rpx;
			color: $text-color;
			line-height: 17rpx;
			margin-top: 10rpx;
			padding-bottom: 20rpx;
		}
		.flex{
			margin-top: 2rpx;
			image{
				width: 28rpx;
				height: 35rpx;
			}
			.text{
				width: 400rpx;
				margin-left: 20rpx;
				margin-bottom: 6rpx;
				text{
					margin-right: 20rpx;
					font-size: 22rpx;
					color: $text-color;
				}
			}
		}
		.progress-cont{
			position: absolute;
			top: 0;
			bottom: 0;
			right: 25rpx;
			margin: auto;
			.progress-text{
				font-size: 25rpx;
				color: $color-main;
				line-height: 17rpx;
				margin-bottom: 24rpx;
			}
			.progress-box{
				width: 185rpx;
				height: 23rpx;
				border-radius: 5rpx;
				overflow: hidden;
				border: 2rpx solid $color-primary;
				position: relative;
				.progress-line{
					position: absolute;
					left: 0;
					top: 0;
					width: var(--width);
					height: 23rpx;
					background-color: $color-primary;
				}
			}
		}
	}
</style>
